<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f= "http://java.sun.com/jsf/core">


    
    <h:head>
        
    </h:head>
    <h:body onload="document.getElementById('form1:nome').focus()">
        <ui:composition template="template.xhtml">
            <ui:define name="centro">
                <p:messages globalOnly="true" showDetail="true"/>
                
                <!--h2><h:messages globalOnly="true" layout="table" showDetail="true" infoStyle="color: blue" warnStyle="color: yellow" errorStyle="color: red"/></h2-->
                <h:form id="form1">
                    <h:inputHidden value="#{manterFornecedorBean.fornecedor.codigo}"/>
                    <h:outputText value="#{mens.NOME}" style="margin-left: 68px" styleClass="outputText"/>
                    <p:inputText id="nome" value="#{manterFornecedorBean.fornecedor.nome}" required="true" size="40">
                        <f:validateLength for="nome" minimum="1" maximum="50"/>
                    </p:inputText>
                    <p:message for="nome"/>
                    <br/>

                    <h:outputText value="#{mens.CNPJ}" style="margin-left: 73px" styleClass="outputText"/>
                    <p:inputMask id="cnpj" mask="99.999.999/9999-99" value="#{manterFornecedorBean.fornecedor.cnpj}" required="true" size="40"/>
                    <p:message for="cnpj"/>
                    <br/>

                    <h:outputText value="#{mens.RAZAO_SOCIAL}" styleClass="outputText"/>
                    <p:inputText id="razaoSocial" value="#{manterFornecedorBean.fornecedor.razaoSocial}" required="true" size="40">
                        <f:validateLength for="razaoSocial" minimum="1" maximum="50"/>
                    </p:inputText>
                    <p:message for="razaoSocial"/>
                    <br/>

                    <h:outputText value="#{mens.TELEFONE}" style="margin-left: 35px" styleClass="outputText"/>
                    <p:inputMask id="telefone" mask="(99)9999-9999" value="#{manterFornecedorBean.fornecedor.telefone}" required="true" size="40"/>
                    <p:message for="telefone"/>
                    <br/>

                    <h:outputText value="#{mens.EMAIL}" style="margin-left: 65px" styleClass="outputText"/>
                    <p:inputText id="email" value="#{manterFornecedorBean.fornecedor.email}" size="40">
                        <f:validateLength for="email" maximum="50"/>
                    </p:inputText>
                    <p:message for="email"/>
                    <br/>

                    <h:outputText value="#{mens.ENDERECO}" style="margin-left: 31px" styleClass="outputText"/>
                    <p:inputText id="endereco" value="#{manterFornecedorBean.fornecedor.endereco}" size="40" >
                        <f:validateLength for="endereco" maximum="50"/>
                    </p:inputText>
                    <p:message for="endereco"/>
                    <br/>

                    <h:commandButton value="#{mens.INSERIR}" action="#{manterFornecedorBean.create}" style="margin-left: 30px"  />
                    <h:commandButton value="#{mens.ALTERAR}" action="#{manterFornecedorBean.edit}" disabled="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                    <h:commandButton value="#{mens.EXCLUIR}" action="#{manterFornecedorBean.destroy}" disabled="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                </h:form>

                <br/>
                <h:form>
                    <h:commandButton value="#{mens.PESQUISAR}" action="#{manterFornecedorBean.findFornecedorEntities}" style="margin-left: 30px"/>
                    <p:dataTable paginator="true" rows="4" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5" var="f" emptyMessage="#{mens.TABELA_VAZIA}" value="#{manterFornecedorBean.fornecedores}" style="width:620px" rendered="#{manterFornecedorBean.exibeTabela}">
                        <p:column style="width: 103px; max-width: 103px">
                            <f:facet name="header">
                                <h:outputText value="#{mens.NOME}"/>
                            </f:facet>
                            <h:commandLink style="color: maroon; font-weight: bolder" value="#{f.nome}" action="paginaManterFornecedor.xhtml">
                                <f:setPropertyActionListener value="#{f.codigo}" target="#{manterFornecedorBean.fornecedor.codigo}"/>
                                <f:setPropertyActionListener value="#{f.nome}" target="#{manterFornecedorBean.fornecedor.nome}"/>
                                <f:setPropertyActionListener value="#{f.cnpj}" target="#{manterFornecedorBean.fornecedor.cnpj}"/>
                                <f:setPropertyActionListener value="#{f.razaoSocial}" target="#{manterFornecedorBean.fornecedor.razaoSocial}"/>
                                <f:setPropertyActionListener value="#{f.telefone}" target="#{manterFornecedorBean.fornecedor.telefone}"/>
                                <f:setPropertyActionListener value="#{f.email}" target="#{manterFornecedorBean.fornecedor.email}"/>
                                <f:setPropertyActionListener value="#{f.endereco}" target="#{manterFornecedorBean.fornecedor.endereco}"/>
                                <f:setPropertyActionListener value="false" target="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                            </h:commandLink>
                        </p:column>
                        <p:column style="width: 100px; max-width: 100px;">
                            <f:facet name="header">
                                <h:outputText value="#{mens.CNPJ}"/>
                            </f:facet>
                            <h:outputText value="#{f.cnpj}"/>
                        </p:column>
                        <p:column style="width: 103px">
                            <f:facet name="header">
                                <h:outputText value="#{mens.RAZAO_SOCIAL}"/>
                            </f:facet>
                            <h:outputText value="#{f.razaoSocial}"/>
                        </p:column>
                        <p:column style="width: 70px; max-width: 70px;">
                            <f:facet name="header">
                                <h:outputText value="#{mens.TELEFONE}"/>
                            </f:facet>
                            <h:outputText value="#{f.telefone}"/>
                        </p:column>
                        <p:column style="width: 103px">
                            <f:facet name="header">
                                <h:outputText value="#{mens.EMAIL}"/>
                            </f:facet>
                            <h:outputText value="#{f.email}"/>
                        </p:column>

                        <p:column style="width: 103px">
                            <f:facet name="header">
                                <h:outputText value="#{mens.ENDERECO}"/>
                            </f:facet>
                            <h:outputText value="#{f.endereco}"/>
                        </p:column>

                    </p:dataTable>

                </h:form>

            </ui:define>
        </ui:composition>
    </h:body>
</html>

